package com.lagou.edu;

import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.JedisPoolConfig;

import java.util.HashSet;
import java.util.Set;

/**
 * @Author: yeqingyun
 * @Date: 2021/2/19 17:00
 */
public class JedisClusterMain {

    public static void main(String[] args) {
        JedisPoolConfig config = new JedisPoolConfig();
        Set<HostAndPort> jedisClusterNode = new HashSet<HostAndPort>();
        jedisClusterNode.add(new HostAndPort("127.0.0.1", 7001));
        jedisClusterNode.add(new HostAndPort("127.0.0.1", 7002));
        jedisClusterNode.add(new HostAndPort("127.0.0.1", 7003));
        jedisClusterNode.add(new HostAndPort("127.0.0.1", 7004));
        jedisClusterNode.add(new HostAndPort("127.0.0.1", 7005));
        jedisClusterNode.add(new HostAndPort("127.0.0.1", 7006));
        jedisClusterNode.add(new HostAndPort("127.0.0.1", 7007));
        jedisClusterNode.add(new HostAndPort("127.0.0.1", 7008));
        JedisCluster jcd = new JedisCluster(jedisClusterNode, config);
        jcd.set("name:001", "zhangfei");
        String value = jcd.get("name:001");

        System.out.println("name:001=" + value);

        jcd.set("name:004", "lvbu");
        String value2 = jcd.get("name:004");
        System.out.println("name:004=" + value2);
    }
}
